package com.atguigu.gulimall.order.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Classname MybatisConfig
 * @Description 要想得到总记录数和总页码，必须要有plus的这个拦截器
 * @Date 2021/8/5 16:35
 * @Author Anonymous
 */
@SuppressWarnings("all")
@Configuration  //表示这是一个配置类
@MapperScan("com.atguigu.gulimall.order.dao") //开启mapper接口扫描
public class MybatisConfig {
    //引入分页插件，详见官方文档
    // 最新版
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.H2));
        return interceptor;
    }
}
